package com.example.sportgoods.Service.impl;

import com.example.sportgoods.Service.LogisticsService;
import com.example.sportgoods.domain.Logistics;
import com.example.sportgoods.domain.Order;
import com.example.sportgoods.mapper.LogisticsMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogisticsServiceImpl implements LogisticsService {

    private static final Logger log = LoggerFactory.getLogger(LogisticsServiceImpl.class);

    // 自动注入LogisticsMapper，用于后续调用其与数据库交互的方法
    @Autowired
    private LogisticsMapper logisticsMapper;

    // 实现获取所有物流信息的方法，调用LogisticsMapper的getAll方法从数据库获取
    @Override
    public List<Logistics> selectAllLogistics() {
        return logisticsMapper.getAll();
    }

    // 实现根据id查询物流信息的方法，调用LogisticsMapper的selectLogisticsById方法
    @Override
    public Logistics selectLogisticsById(Long id) {
        return logisticsMapper.selectLogisticsById(id);
    }
    // 更新物流信息的业务方法，调用LogisticsMapper的对应方法将传入的物流对象信息更新到数据库中
    @Override
    public int updateLogistics(Logistics logistics) {
        return logisticsMapper.updateLogistics(logistics);
    }

    // 新增物流记录的业务方法，调用LogisticsMapper的对应方法将传入的物流对象插入到数据库中
    @Override
    public void addLogistics(Logistics logistics) {
        logisticsMapper.insertLogistics(logistics);
    }

    // 根据物流单号删除物流记录的业务方法，调用LogisticsMapper的对应方法从数据库中删除指定单号的物流记录
    @Override
    public void deleteLogisticsById(Long id) {
        logisticsMapper.deleteLogisticsById(id);
    }
}